package com.zkflzl.store.controller;

import com.zkflzl.store.common.BaseResponse;
import com.zkflzl.store.model.dto.stock.StockAddRequest;
import com.zkflzl.store.model.dto.stock.StockListRequest;
import com.zkflzl.store.model.dto.stock.StockOutRequest;
import com.zkflzl.store.service.StockService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/stock")
@Api(tags = "库存模块")
public class StockController {

    @Resource
    private StockService stockService;
    /**
     * 添加库存
     */
    @PostMapping("/in")
    public BaseResponse inStock(@RequestBody StockAddRequest stockAddRequest, HttpServletRequest request) {
        return stockService.inStock(stockAddRequest,request);
    }

    /**
     * 出库
     */
    @PostMapping("/out")
    public BaseResponse outStock(@RequestBody StockOutRequest stockOutRequest, HttpServletRequest request) {
        return stockService.outStock(stockOutRequest,request);
    }
    /**
     * 更新库存
     */
    @PostMapping("/update")
    public BaseResponse updateStock(@RequestParam Long id,@RequestParam Long quantity, HttpServletRequest request) {
        return stockService.updateStock(id,quantity,request);
    }

    /**
     * 删除库存
     */
    @PostMapping("/del")
    public BaseResponse delStock(@RequestParam String stockId, HttpServletRequest request) {
        return stockService.delStock(stockId,request);
    }

    /**
     * 查询库存
     */
    @PostMapping("/sel")
    public BaseResponse selStock(@RequestBody StockListRequest stockListRequest, HttpServletRequest request) {
        return stockService.selStock(stockListRequest,request);
    }
}



